package com.serviceimpl;

import com.dao.UserDao;
import com.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao UserDaoImpl;

    @Override
    //事务注解 添加该注解的方法 会自动进行事务的管理
    //可以通过注解属性 设置隔离级别 传播级别 超时时间 是否只读
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,timeout = -1,readOnly = false)
    public void exchangeDesc(String name1, String name2, String desc1, String desc2) {
        UserDaoImpl.updateDescByName(name1,desc1);
        System.out.println(1/0);
        UserDaoImpl.updateDescByName(name2,desc2);
    }

}
